import { Toast, Loading, Field } from 'vant'
class _showTip {
  constructor() {}
  ShowTip(tip, t = 0.5, code = 0) {
    console.log('提示：', tip, code)
    Toast.clear()
    let locale = localStorage.getItem('locale')
    let obj = {}

    if (typeof code === 'string') {
      code = parseInt(code)
    }
    if (code != 0) {
      switch (code) {
        case 10000:
          //提示：账号改变了，请刷新
          obj = {
            zh: '帳號改變了，請重繪',
            en: 'Account changed, please refresh'
          }
          break
        case 10001:
          //提示：链接错误
          obj = {
            zh: '連結錯誤',
            en: 'link error'
          }
          break
        case 10002:
          //提示：网络错误，请使用正确的网络
          obj = {
            zh: '網絡錯誤，請使用正確的網絡',
            en: 'Network error, please use the correct network'
          }
          break
        case 10003:
          //提示： 没链接到小狐狸
          obj = {
            zh: '沒連結到小狐狸',
            en: 'No link to little fox'
          }
          break
        case 10004:
          //提示：授权成功
          obj = {
            zh: '授權成功',
            en: 'Authorization succeeded'
          }
          break
        case 10005:
          //提示：授权失败
          obj = {
            zh: '授權失敗',
            en: 'privilege grant failed'
          }
          break
        
        case 1101:
          obj = {
            zh: '邀請地址不存在！',
            en: 'address does not exist!'
          }
          break
        case 1001:
          obj = {
            zh: '服務未開放！',
            en: 'service is not start!'
          }
          break
        case 1102:
          obj = {
            zh: '數量有誤！',
            en: 'amount wrong!'
          }
          break
        case 1103:
          obj = {
            zh: '列表長度不一致！',
            en: 'inconsistent length!'
          }
          break
        case 1104:
          obj = {
            zh: '庫存不足！',
            en: 'insufficient stock!'
          }
          break
        case 1105:
          obj = {
            zh: '暫未開始！',
            en: 'no started!'
          }
          break
        case 1106:
          obj = {
            zh: '數量有誤！',
            en: 'amount wrong!'
          }
          break
        case 1107:
          obj = {
            zh: '數量超出限制！',
            en: 'amount exceed!'
          }
          break
        case 1108:
          obj = {
            zh: '今日已空投！',
            en: 'airdropping today!'
          }
          break
        case 1109:
          obj = {
            zh: '獎勵數量不足！',
            en: 'insufficient quantity!'
          }
          break
        case 1200:
          obj = {
            zh: '未上架！',
            en: 'no shelves!'
          }
          break
        case 1201:
          obj = {
            zh: '未擁有！',
            en: 'not owned!'
          }
          break
        case 1300:
          obj = {
            zh: '輸入參數有誤！',
            en: 'nput wrong!'
          }
          break
        case 1301:
          obj = {
            zh: '空投已領取！',
            en: 'have received!'
          }
          break
        case 1400:
          obj = {
            zh: '库存不足！',
            en: 'insufficient stock!'
          }
          break
        case 1401:
          obj = {
            zh: '已凍結！',
            en: 'frozen!'
          }
        break
        case 1402:
          obj = {
            zh: '未擁有！',
            en: 'not owned!'
          }
          break
        case 1500:
          obj = {
            zh: '資產不足！',
            en: 'lack of funds!'
          }
          break
        case 1600:
          obj = {
            zh: '數量必須大於 0！',
            en: 'amount > 0!'
          }
          break
        case 1601:
          obj = {
            zh: '暫未開始挖礦！',
            en: 'no start!'
          }
          break
        case 1602:
          obj = {
            zh: '質押數量不足！',
            en: 'amount insufficient!'
          }
          break           
        case 1603:
        obj = {
          zh: '未曾質押！',
          en: 'never stake!'
        }
        break
        case 1604:
          obj = {
            zh: '數量有誤！',
            en: 'amount wrong!'
          }
          break           
        case 1605:
        obj = {
          zh: '無可領取收益！',
          en: 'no income!'
        }
        break
        case 1606:
          obj = {
            zh: '數量超出限制！',
            en: 'amount exceeds!'
          }
          break                    
        default:
          obj = {
            zh: '交易失败',
            en: 'Transaction failure'
          }
          break
      }
      Toast(obj[locale])
    } else {
      if (!tip) {
        //提示：交易失败
        obj = {
          zh: '交易失败',
          en: 'Transaction failure'
        }
        tip = obj[locale]
      }
      Toast(tip)
    }
  }
  showWait(message = 'loading') {
    console.log('message', message)
    Toast.loading({
      message: message,
      duration: 0, // 展示时长(ms)，值为 0 时，toast 不会消失
      overlay: false, // 是否显示遮罩层
      forbidClick: true, // 是否禁止背景点击
      closeOnClick: false, // 是否在点击后关闭
      closeOnClickOverlay: false // 是否在点击遮罩层后关闭
    })
  }
  hideWait() {
    Toast.clear()
  }
}
const showTip = new _showTip()
export default showTip
